<?php

// bkt_list.php
// Michael Baker
// 2010.07.12
//
// List thresholding brackets

session_start();

define("IN_MDM", true);
define("CUR_PAGE_TITLE", "Thresholding management");
define("CUR_FLAG", "bkt.list");

include '../includes/all.php';
include 'inc/header.php';

?>
<h2>Bracket list</h2>
<div style="text-align: right;"><a href="bkt_create.php">&raquo; Create bracket</a></div>
<table class="type2p" cellspacing="1">
  <col class="col2" /><col class="col2" /><col class="col1" /><col class="col1" />
  
  <thead>
    <tr>
      <th>Name</th>
      <th>Segments</th>
      <th colspan="2" style="width: 20%">Controls</th>
    </tr>
  </thead>
  
  <tbody>
    <?php
    
    // Retrieve ID=>Title assoc. array of workflows
    $cat_list = $dbase->get_thresholding_categories();
    asort($cat_list);
    
    foreach ( $cat_list as $id => $title )
    {
      echo "<tr>";
      
      $has_bkt_view = has_flag( $uid, "bkt.view" );
      $has_bkt_edit = has_flag( $uid, "bkt.edit" );
      $has_bkt_del  = has_flag( $uid, "bkt.del" );
      
      $viewLink = $has_bkt_view ? ui_create_link( "$title", "bkt_view.php?id=$id" ) : $title;
      $editLink = $has_bkt_edit ? ui_create_link( "Edit", "bkt_edit.php?id=$id" ) : "Edit";
      $delLink  = $has_bkt_del  ? ui_create_link( "Remove", "bkt_del.php?id=$id" ) : "Remove";
      
      echo "<td>"                              . $viewLink . "</td>";
      echo "<td>"                              . count($dbase->get_nodecouples_by_category($id)) . "</td>";
      echo "<td style=\"text-align: center\">" . $editLink . "</td>";
      echo "<td style=\"text-align: center\">" . $delLink  . "</td>";
      
      echo "</tr>";
    }
     
    ?>
  </tbody>
</table>

<?php include 'inc/footer.php'; ?>